#ifndef FIELDMODEL_H
#define FIELDMODEL_H

#include <QAbstractItemModel>
#include "FieldItem.h"
#include "utils.h"

class FieldModel : public QAbstractItemModel
{
    Q_OBJECT

public:
    explicit FieldModel(Format *format, FERange range, void *context, QObject *parent = nullptr);
    ~FieldModel();

    QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;

    QModelIndex parent(const QModelIndex& index) const override;

    int rowCount(const QModelIndex& parent = QModelIndex()) const override;

    int columnCount(const QModelIndex& parent = QModelIndex()) const override;

    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;

signals:
    int rangeChanged(FERange range);

public slots:
    void selectItem(const QModelIndex& index);

private:
    FieldItem* getItem(const QModelIndex& index) const;
    FieldItem* root_item_;
};

#endif // FIELDMODEL_H
